package com.uhylab.uhuvinetest.activity;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;

import com.uhylab.uhuvinetest.R;
import com.uhylab.uhuvinetest.base.UHBaseActivity;

/**
 * Created by xyb on 16/1/19 at UHylab
 *
 * @version 1.0
 */
public class UHWebViewActivity extends UHBaseActivity {
    private ImageView webView_back;
    private WebView webView;

    @Override
    public int bindLayout() {
        return R.layout.activity_webview;
    }

    @Override
    public void initView(View view) {
        webView_back = (ImageView) view.findViewById(R.id.webView_back);
        webView = (WebView) view.findViewById(R.id.webview);
    }

    @Override
    public void doBusiness(Context mContext) {
        Intent intent = getIntent();
        if (intent != null) {
            webView_back.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });
            webView(intent.getStringExtra("url"));
        }


    }

    @Override
    public void resume() {

    }

    @Override
    public void destroy() {

    }


    private void webView(String data) {
        WebSettings webSettings = webView.getSettings();
        webSettings.setDisplayZoomControls(true);
        webSettings.setDefaultFixedFontSize(20);
        //适应屏幕
        webSettings.setAppCacheEnabled(true);
        webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setBuiltInZoomControls(false); // 设置不显示缩放按钮
//        webView.loadDataWithBaseURL(data, null, "text/html", "utf-8", null);
        webView.loadUrl(data);
    }
}
